package com.ki.erp.vo;

import lombok.Data;

@Data
public class R<T> {
    private Integer code;
    private String msg;
    private T data;

    public R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static R success() {
        return new R(200, null, null);
    }

    public static <T> R<T> success(T data) {
        return new R<>(200, null, data);
    }

    public static R fail() {
        return new R(0, "未知错误", null);
    }

    public static R fail(Integer code, String msg) {
        return new R(code, msg, null);
    }

    public static <T> R<T> fail(Integer code, String msg, T data) {
        return new R<>(code, msg, data);
    }

}
